<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

use App\Http\Requests;
use App\Http\Controllers\Controller;
use App\Pro;
use App\Att;
class CheckController extends Controller
{
    /*审核列表*/
    public function prolist(){
        $pros = Pro::orderBy('pid' , 'desc')->get();
        return view('prolist' , ['pros'=>$pros]);
    }
    /*后台审核*/
    public function check($pid){
        $pro = Pro::find($pid);
        //print_r($pro);exit;
        $att = Att::where('pid' , $pid)->first();
        if(empty($pro)){//要判断pro是否为空数组
            return redirect('/prolist');
        }
        return view('shenhe' , ['pro'=>$pro , 'att'=>$att]);
    }
    /*提交审核资料*/
    public function checkPost(Request $req , $pid){
        $pro = Pro::find($pid);
        $att = Att::where('pid' , $pid)->first();
        //dd($att);exit;
        if(empty($pro)){
            return redirect('/prolist');
        }
        //dd($req->name);exit;
        $att->realname = $req->name;
        $att->gender = $req->gender;
        $att->salary = $req->salary * 100;
        $att->marry = $req->marry;
        $att->jobcity = $req->jobcity;
        $att->udesc = $req->udesc;

        $pro->title = $req->title;
        $pro->money = $req->money * 100;
        $pro->hrange = $req->hrange;
        $pro->status = $req->status;
        $pro->rate = $req->rate;
        
        if($att->save() && $pro->save()){
            return redirect('/prolist');
        }else{
            echo "error";
        }
    }
}








